/**
 * @param {number[]} nums
 * @return {number}00-52
 */
console.log(removeDuplicates([1, 1, 2]));

function removeDuplicates(nums) {

    if (nums.length <= 1) { return nums.length; }

    for (i = 0; i < nums.length - 1; i++) { //length
        if (nums[i + 1] == nums[i]) {
            delete nums[i + 1];

            if (nums[i + 2] != undefined) {
                for (j = i + 2; j < nums.length; j++) {
                    nums[j - 1] = nums[j];
                }
            }
            nums.length--; //length解决
            i--; //删除问题，解决
        }

    }
    return nums.length; //length解决
};